import {Component, OnInit} from "@angular/core";
import {PersonService} from "../persion.service";
import {ms_resetPasswordFromSource} from "../../model/ms_resetPasswordFromSource";
import {BaseComponent} from "../../base.component";


@Component({
    selector: 'my-rightContent',
    templateUrl: "./persion.reset.password.html",
    styleUrls: ["./persion.reset.password.css"]
})
export class ResetPasswordCompontent extends BaseComponent implements OnInit {

    isAjax:boolean=false;

    resetPassword: ms_resetPasswordFromSource = new ms_resetPasswordFromSource();

    ngOnInit(): void {

    }

    constructor(private server: PersonService) {
        super()
    }


    submit() {
        this._message = "";
        this.isAjax=true;
        this.server.modifyPassword(this.resetPassword)
            .then(response => {
                this.isAjax=false;
                if (response.result) {
                    this.dialog.successShow("密码修改成功");
                    this.resetPassword=new ms_resetPasswordFromSource();
                } else {
                    this._message=response.message;
                }
            })
            .catch(ex => this.setMessage(ex, null, true));

    }



    validator():boolean{
        let result= this.resetPassword.validator();
        this._message=result.message;
        return result.result;
    }

}
